﻿using System;
namespace Linq
{
    class Linq
    {
        public static void Main()
        {
            int[] a = new int[100];
            Random rd = new Random();
            for (int i = 0; i < a.Length; i++) //生成100个随机数
            {
                a[i] = rd.Next(0, 1000);
            }
            var m = from n in a orderby n descending select n; //Linq语句从大到小排序
            foreach (var n in m)
            {
                Console.WriteLine(n);
            }
            var sum = a.Sum();
            Console.WriteLine("总和为："+sum);
            var average = a.Average();
            Console.WriteLine("平均值为："+average);
        }
    }
}
